#include"comm.hpp"
// int main()
// { 
  
//   int shmid = GetShm();
//   _log(Debug,"create shm done!");
//   sleep(3);
//   char* shmaddr = (char*)shmat(shmid,nullptr,0);
//   //关联
//   _log(Debug,"attach shm done!,shnaddr: 0x%x",shmaddr);
 
  

//   sleep(3);
//   shmdt(shmaddr);//去关联
//   _log(Debug,"detach shm done,shmaddr:0x%x",shmaddr);

//   return 0;
// }

int main()
{ 
  
  int shmid = GetShm();
  char* shmaddr = (char*)shmat(shmid,nullptr,0);
  //ipc code
  int pos = 0;
  //一旦有了共享内存,挂接到自己的地址空间后,你直接把他当成你的
  //内存空间来使用即可
  //不需要调用系统调用。
   while(1)
   {
    //  char buff[1024];
    //  cout << "Please Enter@ ";
    //  fgets(buff,sizeof(buff),stdin);
    //  memcpy(shmaddr,buff,strlen(buff) + 1);
     cout << "Please Enter@ ";
     fgets(shmaddr,4096,stdin);
   }
  shmdt(shmaddr);
  return 0;
}